<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>新增拜访记录</title>
    <!--{include file='comm/comm_region.tpl'}-->
</head>

<body>

<div class="panel panel-default">

    <div class="comm_right">
        <div class="comm_crub">
            <span class="now_crub">拜访记录</span>
        </div>

        <div class="comm_content">

            <div class="panel-body">

                <form id="item_form" onsubmit="return false;" class="form-horizontal" style="position:relative">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">
                            客户信息：
                        </label>
                        <div class="col-sm-6">
                            <select class="form-control" id="company" name="company">
                                <!--{foreach from=$companyList item=company}-->
                                <!--{if $companyId && $companyId == $company.company_id}-->
                                <option value="<!--{$company.company_id}-->" selected><!--{$company.company_name}--></option>
                                <!--{else}-->
                                <option value="<!--{$company.company_id}-->"><!--{$company.company_name}--></option>
                                <!--{/if}-->
                                <!--{/foreach}-->
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">
                            联系人：
                        </label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="contacts" name="contacts">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">
                            联系电话：
                        </label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="mobile" name="mobile">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">
                            拜访时间：
                        </label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="recordDate" name="recordDate" readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">
                            拜访地点：
                        </label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="address" name="address">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">
                            拜访内容：
                        </label>
                        <div class="col-sm-6">
                            <textarea id="remark" class="form-control" rows="3" name="content"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">
                            问题反馈：
                        </label>
                        <div class="col-sm-6">
                            <textarea id="remark" class="form-control" rows="3" name="feedback"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">
                            意见与建议：
                        </label>
                        <div class="col-sm-6">
                            <textarea id="remark" class="form-control" rows="3" name="opinion"></textarea>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="bottom_fixbox" style="margin-left: 0px;width: 100%;left: 0px; height: 46px;">
            <div class="tac" style="background: #dddddd;">
                <input type="button" class="btn btn-primary" onclick="save()" value="保存" />&nbsp;&nbsp;&nbsp;
                <input type="button" class="btn btn-default" onclick="E.closeWindows();" value="关闭" />
            </div>
        </div>

    </div>

</div>

<script type="text/javascript">
    $(function () {
        $('#recordDate').datepicker();
    })

    function save() {
        var dt = E.getFormValues('item_form');
        var error_msg = '';
        if (E.isEmpty(dt.company))
            error_msg += '请选择客户<br/>';

        if (E.isEmpty(dt.contacts))
            error_msg += '请填写联系人<br/>';

        if (E.isEmpty(dt.mobile))
            error_msg += '请填写联系电话<br/>';

        if (E.isEmpty(dt.recordDate))
            error_msg += '请选择拜访时间<br/>';

        if (E.isEmpty(dt.address))
            error_msg += '请填写拜访地址<br/>';

        if (E.isEmpty(dt.content))
            error_msg += '请填写拜访内容<br/>';

        if (error_msg != '') {
            E.alert(error_msg);
            return;
        }
        E.ajax_post({
            url:"/invokingAjax-backend/company/company.ajax?operFlg=5",
            data: dt,
            call: function (o) {
                if (o.code == 200) {
                    E.alert(o.message, 2, function () {
                        <!--{if $companyId == 0}-->
                        E.opener('load');
                        <!--{/if}-->
                        E.closeWindows();
                    });
                } else {
                    E.alert(o.message)
                }
            }
        });
    }
</script>

</body>
</html>